<?php

namespace App\Admin\Controllers;

use App\Models\SalesPersonnelCompany;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class SalesPersonnelCompanyController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = '销售人员或公司信息';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new SalesPersonnelCompany());

        $grid->column('id', __('Id'));
        $grid->column('customer_type_id', trans('exhibitor_information.customer_type'))->using(trans('exhibitor_information.customer_type_array'));
        $grid->column('personnel_companies', '公司名称或者人员名称');
        $grid->column('created_at', '创建时间');

        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(SalesPersonnelCompany::findOrFail($id));

        $show->field('customer_type_id', trans('exhibitor_information.customer_type'))->using(trans('exhibitor_information.customer_type_array'));
        $show->field('personnel_companies', '公司名称或者人员名称');

        $show->field('created_at', '创建时间');

        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new SalesPersonnelCompany());
        $form->select('customer_type_id', trans('exhibitor_information.customer_type'))->options(trans('exhibitor_information.customer_type_array'));
        $form->text('personnel_companies', '公司名称或者人员名称');

        return $form;
    }
}
